package com.niuwa.p2p.service.fund;

import java.util.List;
import java.util.Map;

import com.niuwa.p2p.core.mvc.entity.PageBean;
import com.niuwa.p2p.entity.fund.AcctApply;
import com.niuwa.p2p.entity.fund.ApplyAcctLog;
import com.niuwa.p2p.entity.fund.BaseAccount;
import com.niuwa.p2p.entity.fund.ChannelAccount;
import com.niuwa.p2p.entity.fund.ChlAcctRule;
import com.niuwa.p2p.entity.fund.CustAccount;
import com.niuwa.p2p.entity.fund.CustAcctRule;

public interface FundAccountService {
	/**
	 * 获取客户账号分页列表
	 * @return
	 */
	public PageBean<BaseAccount> searchCustomerPage(Map<String, Object> paramMap);
	
	/**
	 * 获取渠道账号分页列表
	 * @param paramMap
	 * @return
	 */
	public PageBean<BaseAccount> searchChanelPage(Map<String,Object> paramMap);

	/**
	 * 获取所有渠道账号数据
	 * @return
	 */
	public List<ChannelAccount> getAllChannelAccount();
	
	/**
	 * 获取账号申请列表
	 * @param paramMap
	 * @return
	 */
	public PageBean<AcctApply> searchAcctApplyPage(Map<String,Object> paramMap);
	/**
	 * 检查渠道账号是否存在
	 * @param acctNo
	 * @return
	 */
	public boolean isContainsAcctNo(String acctNo);
	
	/**
	 * 插入操作日志
	 * @param allyAcctLog
	 * @return
	 */
	public boolean insertApplyAcctLog(ApplyAcctLog allyAcctLog);
	/**
	 * 更新账户申请
	 * @param acctApply
	 * @return
	 */
	public boolean updateByPrimaryKeySelective(AcctApply acctApply);
	 /**
     * 获取账号申请最新审核
     * @param map
     * @return
     */
    ApplyAcctLog getNewestAudit(String applyNo);
    /**
     * 根据主键获取资金客户账号
     * @param accountNo
     * @return
     */
    CustAccount getCustAccoutByKey(String accountNo);
    /**
     * 通过主键获取资金客户账号的规则
     * @param ruleId
     * @return
     */
    CustAcctRule getCustAcctRule(Long ruleId);
    /**
     * 根据机构编号获取机构规则
     * @param openOrgNo
     * @return
     */
    CustAcctRule getRuleByOpenOrgNo(String openOrgNo);
    
    /**
     * 获取渠道账号规则
     * @param openOrgNo
     * @return
     */
   ChlAcctRule  getChlRuleByOpenOrgNo(String openOrgNo);
   
   /**
    * 插入基本账户信息
    * @param baseAccount
    * @return
    */
   boolean insertBaseAccount(BaseAccount baseAccount);
   
   /**
    * 插入渠道账号信息
    * @param channelAccount
    * @return
    */
   boolean insertChannelAccount(ChannelAccount channelAccount);
   
   /**
    * 插入渠道账户规则
    * @param chlAcctRule
    * @return
    */
   Long insertChlAcctRule(ChlAcctRule chlAcctRule);
   /**
    * 根据账号查询基本资料
    * @param acctNo
    * @return
    */
   BaseAccount getBaseAccountByAcctNo(String acctNo);
   
   ChannelAccount getChannelAccountByAcctNo(String acctNo);
   
   ChlAcctRule getChlAcctRuleById(Long id);
   
   public boolean saveChannelAccount(BaseAccount baseAccount,ChannelAccount channelAccount,ChlAcctRule chlAcctRule);
   
   public boolean updateChannelAccount(BaseAccount baseAccount,ChannelAccount channelAccount,ChlAcctRule chlAcctRule);
   public boolean updateChannelAccount(BaseAccount baseAccount,
			ChannelAccount channelAccount, ChlAcctRule chlAcctRule,CustAcctRule custAcctRule);
   public boolean updateCustAccount(BaseAccount baseAccount,CustAccount CustAccount,CustAcctRule custAcctRule);
   /**
  	 * 账号审核通过
  	 * @return
  	 */
   public boolean saveAcctApplyPass(String applyNo,Long userId);
   /**
	 * 账号审核拒绝
	 * @return
	 */
	public boolean saveAcctApplyReject(String applyNo,Long userId,String reason);
	
	
	/**
	 * 资金账户【web】
	 * @param custId 客户Id
	 * @return Account 账户实体
	 */
	public CustAccount getAccountInfoByCustId(long custId);
	
	//TODO 交易相关 review - 开户回调
	/**
	 * 创建资金账户【web】
	 * @param paramMap
	 * @return
	 */
	public boolean saveFundAccount(Map<String, Object> paramMap) throws Exception;
	
	//TODO 交易相关 review - 充值回调
	/**
	 * 资金账户充值【web】
	 * @param paramMap
	 * @return
	 */
	public boolean fundAccountRecharge(Map<String, Object> paramMap) throws Exception;
	
	//TODO 交易相关 review - 提现回调
	/**
	 * 资金账户提现【web】
	 * @param paramMap
	 * @return
	 */
	public boolean fundAccountWithdraw(Map<String, Object> paramMap) throws Exception;
	
	//TODO 交易相关 review - 充值完成后对账
	/**
	 * 充值完成后对账【web】
	 * @param paramMap
	 * @return
	 */
	public boolean rechargeReconciliation(Map<String, Object> paramMap) throws Exception;
	
	//TODO 交易相关 review - 提现完成后对账
	/**
	 * 提现完成后对账【web】
	 * @param paramMap
	 * @return
	 */
	public boolean withdrawReconciliation(Map<String, Object> paramMap) throws Exception;
	
	//TODO 交易相关 review - 禁用资金账户
	/**
	* 提现完成后对账【web】
	* @param paramMap
	* @return
	*/
	public boolean disableFundAccount(Map<String, Object> paramMap) throws Exception;
   
}
